{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b1ffed6d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.2.5\n",
      "1.21.0\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "print(pd.__version__)\n",
    "print(np.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "72cd142e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.series.Series'>\n",
      "0    1.0\n",
      "1    3.0\n",
      "2    5.0\n",
      "3    NaN\n",
      "4    6.0\n",
      "5    8.0\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "#Series\n",
    "s = pd.Series([1, 3, 5, np.nan, 6, 8])\n",
    "\n",
    "print(type(s))\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e037b0d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.indexes.datetimes.DatetimeIndex'>\n",
      "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
      "               '2013-01-05', '2013-01-06'],\n",
      "              dtype='datetime64[ns]', freq='D')\n"
     ]
    }
   ],
   "source": [
    "#DatetimeIndex\n",
    "dates = pd.date_range('20130101', periods=6)\n",
    "\n",
    "print(type(dates))\n",
    "print(dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c2c6dbd4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>1.679679</td>\n",
       "      <td>0.326772</td>\n",
       "      <td>-0.817938</td>\n",
       "      <td>0.127795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-1.159733</td>\n",
       "      <td>0.200811</td>\n",
       "      <td>-1.258112</td>\n",
       "      <td>-1.563113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>0.373308</td>\n",
       "      <td>-0.827578</td>\n",
       "      <td>0.557230</td>\n",
       "      <td>-0.098317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>1.480522</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>0.589843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.609787</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.775368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.528523</td>\n",
       "      <td>-1.124800</td>\n",
       "      <td>-0.299971</td>\n",
       "      <td>0.265376</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01  1.679679  0.326772 -0.817938  0.127795\n",
       "2013-01-02 -1.159733  0.200811 -1.258112 -1.563113\n",
       "2013-01-03  0.373308 -0.827578  0.557230 -0.098317\n",
       "2013-01-04  1.480522 -0.656651 -2.077668  0.589843\n",
       "2013-01-05 -1.609787 -0.023188  1.275050 -0.775368\n",
       "2013-01-06  0.528523 -1.124800 -0.299971  0.265376"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#DateFrame\n",
    "df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns = list('ABCD'))\n",
    "\n",
    "print(type(df))\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3cf66663",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    float64\n",
       "B    float64\n",
       "C    float64\n",
       "D    float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "646a324b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>1.679679</td>\n",
       "      <td>0.326772</td>\n",
       "      <td>-0.817938</td>\n",
       "      <td>0.127795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-1.159733</td>\n",
       "      <td>0.200811</td>\n",
       "      <td>-1.258112</td>\n",
       "      <td>-1.563113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>0.373308</td>\n",
       "      <td>-0.827578</td>\n",
       "      <td>0.557230</td>\n",
       "      <td>-0.098317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>1.480522</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>0.589843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.609787</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.775368</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-01  1.679679  0.326772 -0.817938  0.127795\n",
       "2013-01-02 -1.159733  0.200811 -1.258112 -1.563113\n",
       "2013-01-03  0.373308 -0.827578  0.557230 -0.098317\n",
       "2013-01-04  1.480522 -0.656651 -2.077668  0.589843\n",
       "2013-01-05 -1.609787 -0.023188  1.275050 -0.775368"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7ad56090",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>1.480522</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>0.589843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.609787</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.775368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.528523</td>\n",
       "      <td>-1.124800</td>\n",
       "      <td>-0.299971</td>\n",
       "      <td>0.265376</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-04  1.480522 -0.656651 -2.077668  0.589843\n",
       "2013-01-05 -1.609787 -0.023188  1.275050 -0.775368\n",
       "2013-01-06  0.528523 -1.124800 -0.299971  0.265376"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1a8303c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04',\n",
       "               '2013-01-05', '2013-01-06'],\n",
       "              dtype='datetime64[ns]', freq='D')"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4fbc61d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C', 'D'], dtype='object')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a2a4e321",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.67967902,  0.32677185, -0.81793794,  0.12779528],\n",
       "       [-1.15973323,  0.20081095, -1.25811175, -1.56311295],\n",
       "       [ 0.37330751, -0.8275779 ,  0.55723013, -0.09831661],\n",
       "       [ 1.48052157, -0.65665052, -2.07766794,  0.58984317],\n",
       "       [-1.60978683, -0.02318831,  1.27505022, -0.77536804],\n",
       "       [ 0.52852283, -1.12479968, -0.29997054,  0.26537621]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "770f4545",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.215418</td>\n",
       "      <td>-0.350772</td>\n",
       "      <td>-0.436901</td>\n",
       "      <td>-0.242297</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>1.348327</td>\n",
       "      <td>0.598439</td>\n",
       "      <td>1.220616</td>\n",
       "      <td>0.792036</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-1.609787</td>\n",
       "      <td>-1.124800</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>-1.563113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.776473</td>\n",
       "      <td>-0.784846</td>\n",
       "      <td>-1.148068</td>\n",
       "      <td>-0.606105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.450915</td>\n",
       "      <td>-0.339919</td>\n",
       "      <td>-0.558954</td>\n",
       "      <td>0.014739</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1.242522</td>\n",
       "      <td>0.144811</td>\n",
       "      <td>0.342930</td>\n",
       "      <td>0.230981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>1.679679</td>\n",
       "      <td>0.326772</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>0.589843</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              A         B         C         D\n",
       "count  6.000000  6.000000  6.000000  6.000000\n",
       "mean   0.215418 -0.350772 -0.436901 -0.242297\n",
       "std    1.348327  0.598439  1.220616  0.792036\n",
       "min   -1.609787 -1.124800 -2.077668 -1.563113\n",
       "25%   -0.776473 -0.784846 -1.148068 -0.606105\n",
       "50%    0.450915 -0.339919 -0.558954  0.014739\n",
       "75%    1.242522  0.144811  0.342930  0.230981\n",
       "max    1.679679  0.326772  1.275050  0.589843"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "19c23614",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2013-01-01</th>\n",
       "      <th>2013-01-02</th>\n",
       "      <th>2013-01-03</th>\n",
       "      <th>2013-01-04</th>\n",
       "      <th>2013-01-05</th>\n",
       "      <th>2013-01-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1.679679</td>\n",
       "      <td>-1.159733</td>\n",
       "      <td>0.373308</td>\n",
       "      <td>1.480522</td>\n",
       "      <td>-1.609787</td>\n",
       "      <td>0.528523</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.326772</td>\n",
       "      <td>0.200811</td>\n",
       "      <td>-0.827578</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>-1.124800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>-0.817938</td>\n",
       "      <td>-1.258112</td>\n",
       "      <td>0.557230</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.299971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.127795</td>\n",
       "      <td>-1.563113</td>\n",
       "      <td>-0.098317</td>\n",
       "      <td>0.589843</td>\n",
       "      <td>-0.775368</td>\n",
       "      <td>0.265376</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   2013-01-01  2013-01-02  2013-01-03  2013-01-04  2013-01-05  2013-01-06\n",
       "A    1.679679   -1.159733    0.373308    1.480522   -1.609787    0.528523\n",
       "B    0.326772    0.200811   -0.827578   -0.656651   -0.023188   -1.124800\n",
       "C   -0.817938   -1.258112    0.557230   -2.077668    1.275050   -0.299971\n",
       "D    0.127795   -1.563113   -0.098317    0.589843   -0.775368    0.265376"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "cefd6994",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>D</th>\n",
       "      <th>C</th>\n",
       "      <th>B</th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>0.127795</td>\n",
       "      <td>-0.817938</td>\n",
       "      <td>0.326772</td>\n",
       "      <td>1.679679</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-1.563113</td>\n",
       "      <td>-1.258112</td>\n",
       "      <td>0.200811</td>\n",
       "      <td>-1.159733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>-0.098317</td>\n",
       "      <td>0.557230</td>\n",
       "      <td>-0.827578</td>\n",
       "      <td>0.373308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>0.589843</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>1.480522</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-0.775368</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>-1.609787</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.265376</td>\n",
       "      <td>-0.299971</td>\n",
       "      <td>-1.124800</td>\n",
       "      <td>0.528523</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   D         C         B         A\n",
       "2013-01-01  0.127795 -0.817938  0.326772  1.679679\n",
       "2013-01-02 -1.563113 -1.258112  0.200811 -1.159733\n",
       "2013-01-03 -0.098317  0.557230 -0.827578  0.373308\n",
       "2013-01-04  0.589843 -2.077668 -0.656651  1.480522\n",
       "2013-01-05 -0.775368  1.275050 -0.023188 -1.609787\n",
       "2013-01-06  0.265376 -0.299971 -1.124800  0.528523"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#沿坐标轴排序\n",
    "df.sort_index(axis = 1, ascending =False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "70eab232",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2013-01-06</th>\n",
       "      <td>0.528523</td>\n",
       "      <td>-1.124800</td>\n",
       "      <td>-0.299971</td>\n",
       "      <td>0.265376</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-03</th>\n",
       "      <td>0.373308</td>\n",
       "      <td>-0.827578</td>\n",
       "      <td>0.557230</td>\n",
       "      <td>-0.098317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-04</th>\n",
       "      <td>1.480522</td>\n",
       "      <td>-0.656651</td>\n",
       "      <td>-2.077668</td>\n",
       "      <td>0.589843</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-05</th>\n",
       "      <td>-1.609787</td>\n",
       "      <td>-0.023188</td>\n",
       "      <td>1.275050</td>\n",
       "      <td>-0.775368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-1.159733</td>\n",
       "      <td>0.200811</td>\n",
       "      <td>-1.258112</td>\n",
       "      <td>-1.563113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>1.679679</td>\n",
       "      <td>0.326772</td>\n",
       "      <td>-0.817938</td>\n",
       "      <td>0.127795</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   A         B         C         D\n",
       "2013-01-06  0.528523 -1.124800 -0.299971  0.265376\n",
       "2013-01-03  0.373308 -0.827578  0.557230 -0.098317\n",
       "2013-01-04  1.480522 -0.656651 -2.077668  0.589843\n",
       "2013-01-05 -1.609787 -0.023188  1.275050 -0.775368\n",
       "2013-01-02 -1.159733  0.200811 -1.258112 -1.563113\n",
       "2013-01-01  1.679679  0.326772 -0.817938  0.127795"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#按数值排序\n",
    "df.sort_values(by='B')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
